import { ChatOllama } from "@langchain/ollama";
import { HumanMessage } from "@langchain/core/messages";
import { StringOutputParser } from "@langchain/core/output_parsers";

const chatModel = new ChatOllama({
  model: "llama3",
  temperature: 0.7,
});

const parser = new StringOutputParser();

const chain = chatModel.pipe(parser);

const response = await chain.stream([new HumanMessage("Tell me a joke")]);

for await(const chunk of response){
    process.stdout.write(chunk)
}
